package org.example.dubbo.con.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.example.dubbo.api.entity.User;
import org.example.dubbo.api.service.UserService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("con")
@Slf4j
public class ConsumerUserController {

    @DubboReference(protocol = "dubbo",loadbalance = "random")
    private UserService userService;

    @RequestMapping("/user/{id}")
    public User getUserInfo(@PathVariable("id") long id){
        User user = userService.queryUserInfo(id);
        log.info("response from producer:{}",user);
        return user;
    }
}